package com.ruoyi.web.controller.docs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.docs.domain.BizPeopleActivity;
import com.ruoyi.docs.service.IBizPeopleActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动参与Controller
 * 
 * @author ruoyi
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/docs/peopleActivity")
public class BizPeopleActivityController extends BaseController
{
    @Autowired
    private IBizPeopleActivityService bizPeopleActivityService;

    /**
     * 查询活动参与列表
     */
    @PreAuthorize("@ss.hasPermi('docs:peopleActivity:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizPeopleActivity bizPeopleActivity)
    {
        startPage();
        List<BizPeopleActivity> list = bizPeopleActivityService.selectBizPeopleActivityList(bizPeopleActivity);
        return getDataTable(list);
    }

    /**
     * 导出活动参与列表
     */
    @PreAuthorize("@ss.hasPermi('docs:peopleActivity:export')")
    @Log(title = "活动参与", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizPeopleActivity bizPeopleActivity)
    {
        List<BizPeopleActivity> list = bizPeopleActivityService.selectBizPeopleActivityList(bizPeopleActivity);
        ExcelUtil<BizPeopleActivity> util = new ExcelUtil<BizPeopleActivity>(BizPeopleActivity.class);
        util.exportExcel(response, list, "活动参与数据");
    }

    /**
     * 获取活动参与详细信息
     */
    @PreAuthorize("@ss.hasPermi('docs:peopleActivity:query')")
    @GetMapping(value = "/{peopleActivityId}")
    public AjaxResult getInfo(@PathVariable("peopleActivityId") Long peopleActivityId)
    {
        return success(bizPeopleActivityService.selectBizPeopleActivityByPeopleActivityId(peopleActivityId));
    }

    /**
     * 新增活动参与
     */
    @PreAuthorize("@ss.hasPermi('docs:peopleActivity:add')")
    @Log(title = "活动参与", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizPeopleActivity bizPeopleActivity)
    {
        bizPeopleActivity.setCreateBy(getUsername());
        return toAjax(bizPeopleActivityService.insertBizPeopleActivity(bizPeopleActivity));
    }

    /**
     * 修改活动参与
     */
    @PreAuthorize("@ss.hasPermi('docs:peopleActivity:edit')")
    @Log(title = "活动参与", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizPeopleActivity bizPeopleActivity)
    {
        bizPeopleActivity.setUpdateBy(getUsername());
        return toAjax(bizPeopleActivityService.updateBizPeopleActivity(bizPeopleActivity));
    }

    /**
     * 删除活动参与
     */
    @PreAuthorize("@ss.hasPermi('docs:peopleActivity:remove')")
    @Log(title = "活动参与", businessType = BusinessType.DELETE)
	@DeleteMapping("/{peopleActivityIds}")
    public AjaxResult remove(@PathVariable Long[] peopleActivityIds)
    {
        return toAjax(bizPeopleActivityService.deleteBizPeopleActivityByPeopleActivityIds(peopleActivityIds));
    }
}
